Skip to content

fix(web): Fix carousel perf issue + improvements to withAuth middleware#507

Merged
brendan-kellam merged 8 commits intomainfrom
bkellam/fix_503
Sep 16, 2025
Merged

fix(web): Fix carousel perf issue + improvements to withAuth middleware#507
brendan-kellam merged 8 commits intomainfrom
bkellam/fix_503

Conversation

@brendan-kellam
Copy link
Copy Markdown
Contributor

@brendan-kellam brendan-kellam commented Sep 16, 2025

This PR is two unrelated things:

  1. Fixes [bug] Repository carousel renders home page unusable due to CPU consumption #503 by setting the maximum number of repositories that actually render in the carousel to 15.
  2. Introduces a new middleware functions withAuthV2 and withOptionalAuthV2. Some thoughts:
  • Today, almost every server action and api route uses withAuth and withOrgMembership.
  • There are allot of obtuse things about these functions (e.g., allowAnonymousAccess needs to be explicitly set when the minimum role is GUEST, the api key hash was passed as a param instead of extracting it from the header, etc.)
  • We didn't have any unit tests to verify the business logic that (unfortunately) keeps getting more complicated.

withAuthV2 and withOptionalAuthV2 streamlines things in the following ways:

  • It's a single middleware for 90% of our actions. The other 10% are 1) APIs that need elevated roles (in which case, withMinimumOrgRole can be used), or 2) APIs that require authentication but not membership (e.g., invite redemption).
  • It doesn't take any parameters other than a callback. API keys (if applicable) are grabbed from the request header. This especially makes it easy in API routes.
  • Added a ton of UTs

Currently the getRepos action is using this, but planning on refactoring all actions in a followup PR.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Sep 16, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bkellam/fix_503

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

This comment has been minimized.

cursor[bot]

This comment was marked as outdated.

msukkari
msukkari previously approved these changes Sep 16, 2025
@brendan-kellam brendan-kellam merged commit c9e864d into main Sep 16, 2025
10 checks passed
@brendan-kellam brendan-kellam deleted the bkellam/fix_503 branch September 16, 2025 06:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Repository carousel renders home page unusable due to CPU consumption

2 participants